package com.mall.controller;
import com.mall.pojo.Result;
import com.mall.pojo.login;
import com.mall.service.layoutHeaderService;
import com.mall.service.registerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;

import java.util.Map;

@RestController
public class registerController {
    @Autowired
    private registerService registerService;
    @PostMapping("/register")
    public Result register(@RequestBody login request) {
        registerService.register(request.getAccount(),request.getPassword(),request.getNickName());
        return Result.success();
    };
    @ExceptionHandler(ResponseStatusException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST)
    public Result handleResponseStatusException(ResponseStatusException ex) {
        return Result.error(ex.getReason());
    }
}
